Skip to content

Retire the discovery-extension files an --oldcopy upgrade leaves behind - #1531

Merged
fog-workflows[bot] merged 1 commit into
working-1.6from
oldcopy-retires-discovery-files
Aug 30, 2026
Merged

Retire the discovery-extension files an --oldcopy upgrade leaves behind#1531
fog-workflows[bot] merged 1 commit into
working-1.6from
oldcopy-retires-discovery-files

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Follow-up to #1528, found while deploying it to a live server.

configureHttpd()'s retirement sweep matched *.class.php only. #1528 retired
52 more files the same way — every core page, hook, report and event moved from
lib/{pages,hooks,reports,events}/<lowercase>.<type>.php to
src/<Bucket>/<Class>.php — so on FOG_copy_back_old=yes all 52 survive the
upgrade.

Why this is not the harmless case the existing comment describes

A stale *.class.php is inert: autoload() answers a bare name out of src/
before it consults the scanned class map, so those files are clutter on the
include path and nothing more. That is what the comment in place today says,
and it is true.

A stale *.report.php is found. ReportManagement::loadCustomReports()
merges core's src/Reports with the fileitems() walk that picks up plugin
reports, and that walk reaches lib/reports/ too. Every core report is
discovered twice, and the Reports menu renders each of them twice.

Reproduced, not argued

Restoring the 52 pre-#1528 files into a deployed 1.6 webroot and re-running the
discovery probe:

-REPORTS(17): audit report|file deleter|fleet report|hardware report|…
+REPORTS(30): audit report|audit report|file deleter|file deleter|fleet report|fleet report|…

Worth noting what did not catch it: a full page-and-report HTTP sweep of the
same server — 30 page nodes and all 17 reports, asserting status, body size and
absence of a PHP error — stayed at 52 passed, 0 failed with the stale files in
place. The duplicate is in the menu, and every duplicate link works. Only the
probe that reports what discovery actually found could see it.

The fix

The find asks for the four discovery extensions alongside the class files.
The keep-if-still-shipped test is unchanged, and is what makes the wider match
safe: lib/router/ still ships its .class.php files and they are matched,
tested and kept exactly as before. -maxdepth 2 still holds the bundled-plugin
boundary at lib/plugins/<name>/<dir>/.

Gates

tests/oldcopy-retires-moved-classes.test.sh gains three checks — a retired
file of each of the four kinds is removed, a discovery-extension file the
release still ships is spared, and a bundled plugin's report one level deeper is
left to the fog-plugins release.

Both mutations fail it, run rather than assumed:

mutation result
narrow the find back to *.class.php FAIL a retired page/hook/report/event file is removed
drop the keep test (the obvious wrong fix) FAIL … still ships is left alone, twice

Its extractor also had to change. It lifted the loop out of functions.sh and
stopped at the first done < <(find line; the find is a multi-line -o list
now, so that terminator would cut the snippet mid-command. It stops on -print0
instead.

Suite: 239 passed, 0 failed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VTEiBnDpNrgzu1tSqt1318

configureHttpd()'s retirement sweep matched *.class.php only. GH-1528 retired
52 more files the same way -- every core page, hook, report and event moved
from lib/{pages,hooks,reports,events}/<lowercase>.<type>.php to
src/<Bucket>/<Class>.php -- so on FOG_copy_back_old=yes all 52 survive the
upgrade.

They are not the harmless case the existing comment describes. A stale
*.class.php is inert because autoload() answers a bare name out of src/ first.
A stale *.report.php is FOUND: ReportManagement::loadCustomReports() merges
core's src/Reports with the fileitems() walk that picks up plugin reports, and
that walk reaches lib/reports/ too. Every core report is then discovered twice
and the Reports menu renders each of them twice.

Reproduced on a live 1.6 install rather than argued: restoring the 52
pre-GH-1528 files into a deployed webroot took the discovered report list from
17 entries to 30, 13 of them duplicates. Page and report rendering stayed
green throughout, which is why this needed the discovery probe to see at all.

The keep-if-still-shipped test is unchanged and is what keeps the wider match
safe -- lib/router/ still ships its .class.php files and they are matched,
tested and kept exactly as before.

tests/oldcopy-retires-moved-classes.test.sh gains three checks: a retired file
of each of the four kinds is removed, a discovery-extension file the release
still ships is spared, and a bundled plugin's report one level deeper is left
to the fog-plugins release. Both mutations fail it -- narrowing the find back
to *.class.php, and dropping the keep test, which is the obvious wrong fix.

Its extractor also had to change. It grabbed the loop out of functions.sh and
stopped at the first `done < <(find ` line; the find is a multi-line -o list
now, so that terminator would cut the snippet mid-command. It stops on
-print0 instead.

Co-Authored-By: Claude <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge August 30, 2026 21:56
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Aug 30, 2026
Merged via the queue into working-1.6 with commit 24b7045 Aug 30, 2026
10 checks passed
@mastacontrola
mastacontrola deleted the oldcopy-retires-discovery-files branch August 30, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant